//============================================================================
// Name        : CPrimer.cpp
// Author      : Jon
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using std::cout;
using std::endl;
using std::string;

class Screen {
	//Window_mgr的成员可以访问Screen类的私有部分
//	friend class Window_mgr;
	//Screen类的剩余部分

public:
	typedef std::string::size_type pos;
	Screen() = default; //因为Screen有另一个构造函数
						//所以本函数是必须的
	//cursor被其类内初始值初始化为0
	Screen(pos ht, pos wd, char c) :
			height(ht), width(wd), contents(ht * wd, c) {
	}

	char get() const {       //读取光标处的字符
		return contents[cursor];  //隐式内联
	}

	inline char get(pos ht, pos wd) const; // 显示内联
	Screen &move(pos r, pos c);

	void some_member() const;

private:
	pos cursor = 0;
	pos height = 0, width = 0;
	std::string contents;
	mutable size_t access_ctr;

};
void Screen::some_member() const {
	++access_ctr;
}
inline Screen &Screen::move(pos r, pos c) {
	pos row = r * width;
	cursor = row + c;
	return *this;
}

char Screen::get(pos r, pos c) const { //在类的内部声明称inline
	pos row = r * width;         //计算行的位置
	return contents[row + c];     //返回给定列的字符
}
//class Window_mgr {
//public:
//	//窗口中每个屏幕的编号
//	using ScreenIndex = std::vector<Screen>::size_type;
//	//按照编号將指定的Screen重置为空白
//	void clear(ScreenIndex);
//private:
//	std::vector<Screen> screens { Screen(24, 80, ' ') };
//	void Window_mgr::clear(ScreenIndex i) {
//		//s是一个Screen的引用，指向我们想清空的那个屏幕
//		Screen &s = screens[i];
//		//將那个选定的Screen重置为空白
//
//	}
//
//};

